#include <iostream>
#include <sys/types.h>
#include<vector>
#include <unistd.h>
using namespace std;
#define NUMBER 10

void childProcessRun(int n)
{
    while(true)
    {
        cout<<"我是第"<<n<<"个孩子进程,我的PID:"<<getpid()<<",我的PPID:"<<getppid()<<endl;
        sleep(1);
    }
}

int main()
{

    vector<pid_t> childID;
    for(int i=0;i<NUMBER;i++)
    {
        pid_t id=fork();
        if(id==0)
        {
            childProcessRun(i+1);
        }
        childID.push_back(id);
    }

    cout<<"My child ID:";
    for(auto id:childID)
    {
        cout<<id<<" ";
    }

    while(true)
    {
        cout<<"我是父进程,我的PID:"<<getpid()<<",PPID:"<<getppid()<<endl;
        sleep(1);
    }

}
